﻿using MediatR;
using System;
using SystemHYS.API.Application.command.GualityGroupCommand;
using SystemHYS.Domian;
using SystemHYS.Infrstructre.Interface;
namespace SystemHYS.API.Application.commandler.GualityGroupCommandler
{
    public class GualityGroupUpdateCommandler:IRequestHandler<GualityGroupUpdateCommand,int>
    {
        IGualityGroupRepository GroupRepository;
        public GualityGroupUpdateCommandler(IGualityGroupRepository GroupRepository)
        {
            this.GroupRepository = GroupRepository;
        }

        public async Task<int> Handle(GualityGroupUpdateCommand request, CancellationToken cancellationToken)
        {
            var list = await GroupRepository.GetModelAsnc(request.gualityGroupId);
            list.gualityGroupName=request.gualityGroupName;
            list.gualityGroupNumbering=request.gualityGroupNumbering;
            list.gualityGroupRemark=request.gualityGroupRemark;
            list.AddName=request.AddName;
            list.AddTime=request.AddTime;
            list.UpdateName = "李明";
            list.UpdateTime = DateTime.Now.ToUniversalTime();

            return await GroupRepository.UpdateAsyn(list);
        }
    }
}
